use std::path::PathBuf;

use image::DynamicImage;



pub struct Loader {
    root_path:PathBuf
}

impl Loader {
    pub fn new(root:PathBuf) -> Self {

        Self {
            root_path:root
        }
    } 
}

#[derive(Default)]
pub struct TextureLoadOption {
    is_flip_x:bool,
    is_flip_y:bool
}

impl TextureLoadOption {
    pub const NONE:TextureLoadOption = TextureLoadOption { is_flip_x:false,is_flip_y:false };
    pub const FLIP_X:TextureLoadOption = TextureLoadOption { is_flip_x:true,is_flip_y:false };
    pub const FLIP_Y:TextureLoadOption = TextureLoadOption { is_flip_x:false,is_flip_y:true };
    pub const FLIP_XY:TextureLoadOption = TextureLoadOption { is_flip_x:true,is_flip_y:true };
}

/// load texture
impl Loader {
    fn load_texture(&self,path: &'static str,option:TextureLoadOption) -> DynamicImage {
        let mut img: DynamicImage;

        img = image::open(self.root_path.join(path)).expect("load texture failed");
        
        if option.is_flip_x {
            img = img.fliph()
        }
        if option.is_flip_y {
            img = img.flipv();
        }
        img
    }
}